<%@	page import ="java.util.ArrayList" %>
<%@	page import ="java.util.Iterator" %>
<%@	page import ="java.util.List" %>
<%@	page import ="com.adisi.objetos.Chofer" %>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<jsp:directive.include file="headerComun.jsp" />
<body>
<div class="container">
	<jsp:directive.include file="menuNavegacion.jsp" />
	<% 
		String msg = (String)request.getAttribute("msg");
		String msgType = (String)request.getAttribute("msg_type");
		
		if(msgType==null) msgType = "default";
			if(msg!=null) { 
	%>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#alert_placeholder').append('<div class="alert alert-<%=msgType %> fade in "><button type="button" class="close" data-dismiss="alert">&times;</button><%=msg%></div>');
    	alertTimeout(3000);
	});
    </script>
	<% } %>	
	<div class="row clearfix">	
		<div class="col-md-4 column">
			<h3>Choferes</h3>
		</div>
		<div class="col-md-8 column">
			<form class="navbar-right form-inline" role="login" action="#">
				<div class="form-group">
					<label class="sr-only" for="Search">Buscar</label>
					<input type="text" class="form-control" id="Search" placeholder="Introduce criterio de b&uacute;squeda" style="width: 340px;">
				</div>
				<button type="button" class="btn btn-default" title="Buscar">
					<span class="glyphicon glyphicon-search"></span>
				</button>				
			</form>			
		</div>
	</div>
	<div class="row clearfix">
		<div class="col-md-12 column">
			<div class="table-responsive">
			<%
				ArrayList<Chofer> choferes = null;
				try {
					choferes = (ArrayList<Chofer>)request.getAttribute("choferes");					
				}
				catch(NullPointerException e){
					out.print(e.getMessage());
				}; 
			%>
				<table class="table table-striped table-bordered table-hover">
					<thead>
					    <tr>
							<th>Nombre</th>
							<th>Apellido</th>
							<th>Tel&eacute;fono</th>
							<th>GPS</th>
							<th>Acciones
								<% if(Seguridad.validarUsuarioProceso(usuario, "AltaChofer")) { %>
								<div class="btn-group pull-right btn-group-sm">
									<a type="button" class="btn btn-default " title="Agregar chofer" href="chofer?ad">
										<span class="glyphicon glyphicon-plus" style="color:green"></span>
									</a>
								</div>
								<% } %>
							</th>
						</tr>
					</thead>
					<tbody>
						<%
							
							for(int i = 0; i < choferes.size(); i++) {
								int ui = choferes.get(i).getIdChofer();
						%>
						<tr>
							<td>
								<% if(choferes.get(i).getAlertaCercana()!=null) { %>
										<span class="glyphicon glyphicon-bell <%=choferes.get(i).isAlertaGrave()?"rojo":"naranja"  %>"></span>
								<% } %>
								<%=choferes.get(i).getNombre()%></td>
							<td><%=choferes.get(i).getApellido()%></td>
							<td><%=choferes.get(i).getTelefono() %></td>
							<td><%if(choferes.get(i).tieneGPS()){ %>
							<span class="glyphicon glyphicon-globe"></span>
							<%} %></td>
							<td>
								<div class="btn-group">
									<% if(Seguridad.validarUsuarioProceso(usuario, "ModificaAlerta")) { %>
										<a type="button" href="alerta?Chofer=<%=choferes.get(i).getIdChofer()%>" class="btn <%=choferes.get(i).isAlertaGrave()?"btn-danger":((choferes.get(i).getAlertaCercana()!=null)?"btn-warning":"btn-default") %>" title="Alerta<%= (choferes.get(i).getAlertaCercana()!=null)?(": "+choferes.get(i).getAlertaCercana().getMensaje()):'s' %>">
											<span class="glyphicon glyphicon-bell"></span>
										</a>
									<%} %>
								
									<% if(Seguridad.validarUsuarioProceso(usuario, "ModificaChofer")) { %>
										<a type="button" class="btn btn-default" title="Modificar datos" href="chofer?ed=<%= ui %>">
											<span class="glyphicon glyphicon-edit"></span>
										</a>									
									<%} %>
									<a type="button" class="btn btn-default" title="Imprimir datos" href="chofer?pr=<%= ui %>">
										<span class="glyphicon glyphicon-print"></span>
									</a>
									<% if(Seguridad.validarUsuarioProceso(usuario, "BajaChofer")) { %>
									<a type="button" class="confirm btn btn-default" title="Eliminar" href="chofer?bo=<%= ui %>">
										<span class="glyphicon glyphicon-trash"></span>
									</a>										
									<%} %>
								</div>							
							</td>
						</tr>
						<% }; %>
						
					</tbody>				
				</table>
			</div>
		</div>
	</div>
</div>

</body>
</html>